package com.infoview.db;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class SqlServerTest {
	public static void main(String[] srg) {
		  String ad_pic = "http://127.0.0.1:8080/webchat/ad/gz.png";
		  try {
			  Connection conn = DbUtil.getConnection();
			  
			  if (conn != null) {
				  String sql = "select photo from offlack where city = ?";
				  
				  PreparedStatement pstmt = conn.prepareStatement(sql);
				  
				  pstmt.setString(1, "51");
				  
				  ResultSet rs = pstmt.executeQuery();  //获得查询结果
				  Object rt = null;
				  if (rs.next()) {
					  rt = rs.getObject(1);
				  }
				  
				  ad_pic = (String)rt;
				  
				  pstmt.close();
				  conn.close();
				  
			  }
			  
		  } catch (SQLException e) {
			  e.printStackTrace();
		  }
		  
		  System.out.println("ad_pic = " + ad_pic);
		  
		}
	

}
